﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Isaac_dm
{
    public class IsaacDm:BilibiliDM_PluginFramework.DMPlugin
    {
        private IsaacDmManager manager = null;
        public IsaacDm()
        {
            this.PluginAuth = "frto027";
            this.PluginName = "以撒弹幕遥控器";
            this.PluginDesc = "使用bilibili弹幕遥控以撒！";
            this.PluginCont = "602706150@qq.com";
            this.PluginVer = "v0.0.1";
            this.ReceivedDanmaku += IsaacDm_ReceivedDanmaku;
        }

        private void IsaacDm_ReceivedDanmaku(object sender, BilibiliDM_PluginFramework.ReceivedDanmakuArgs e)
        {
            if (this.Status)
            {
                if (manager != null)
                {
                    manager.ReceivedDamaku(e.Danmaku);
                }
            }
        }

        public override void Admin()
        {
            base.Admin();

            if(this.Status == false)
            {
                MessageBox.Show("请先启用此插件");
                return;
            }
            manager.Show();
        }
        public override void Start()
        {
            base.Start();
            if (manager == null)
                manager = new IsaacDmManager((s)=> { Log(s); }, (s)=> { AddDM(s); });
            manager.Show();
        }
        public override void Stop()
        {
            //base.Stop();
            MessageBox.Show("此插件不支持运行后的禁用，请直接重启弹幕姬");
        }

        public override void DeInit()
        {
            base.DeInit();
            if(manager != null)
            {
                manager.DeInit();
            }
        }
    }
}
